Skip to content

SOF-7915: refactor espresso structure parser, support for non-zero ibrav#157

Open
pranabdas wants to merge 20 commits into
mainfrom
refactor/SOF-7915
Open

SOF-7915: refactor espresso structure parser, support for non-zero ibrav#157
pranabdas wants to merge 20 commits into
mainfrom
refactor/SOF-7915

Conversation

@pranabdas

Copy link
Copy Markdown
Member

ASE parser is limited to ibrav==0, requires intermediate POSCAR generation.

ASE parser is limited to ibrav==0, requires intermediate POSCAR generation.
@pranabdas

Copy link
Copy Markdown
Member Author

pymatgen (at least v2025.10.7) does not handle ibrav != 0 either:

{
  context: { userId: 'RoinSzKaR2RR3srXJ' },
  useCase: 'MaterialsImportFromFile',
  runtime: 3857,
  params: {
    accountId: 'DrPRD4p6htEozr8ki',
    file: {
      content: '&CONTROL\n' +
        "    calculation = 'scf'\n" +
        "    title = ''\n" +
        "    verbosity = 'low'\n" +
        "    restart_mode = 'from_scratch'\n" +
        '    wf_collect = .true.\n' +
        '    tstress = .true.\n' +
        '    tprnfor = .true.\n' +
        "    outdir = './tmp/'\n" +
        "    wfcdir = './tmp/'\n" +
        "    prefix = 'si_u'\n" +
        "    pseudo_dir = './'\n" +
        '/\n' +
        '&SYSTEM\n' +
        '    ibrav = 2\n' +
        '    celldm(1) = 10.26\n' +
        '    nat = 2\n' +
        '    ntyp = 1\n' +
        '    ecutwfc = 40\n' +
        '    ecutrho = 200\n' +
        "    occupations = 'fixed'\n" +
        '    nbnd = 40\n' +
        '/\n' +
        '&ELECTRONS\n' +
        "    diagonalization = 'david'\n" +
        '    diago_david_ndim = 4\n' +
        '    diago_full_acc = .true.\n' +
        '    mixing_beta = 0.3\n' +
        "    startingwfc = 'atomic+random'\n" +
        '/\n' +
        '&IONS\n' +
        '/\n' +
        '&CELL\n' +
        '/\n' +
        'ATOMIC_SPECIES\n' +
        'Si 28.0855 si_pz_gbrv_1.0.upf\n' +
        '\n' +
        'ATOMIC_POSITIONS (alat)\n' +
        '  Si 0.0 0.0 0.0\n' +
        '  Si 0.25 0.25 0.25\n' +
        '\n' +
        'K_POINTS automatic\n' +
        '6 6 6 0 0 0\n' +
        '\n' +
        'HUBBARD (ortho-atomic)\n' +
        'U Si-3p 0.01\n' +
        '\n',
      format: 'espresso-in',
      config: [Object]
    }
  },
  result: '{"fields":{"message":"cannot reshape array of size 0 into shape (3,3)"},"code":"MATERIAL_IMPORT_ERROR","message":""}'
}

@pranabdas pranabdas changed the title SOF-7915: refactor espresso structure parser to use pymatgen SOF-7915: refactor espresso structure parser to use qe-tools May 23, 2026
Comment thread pyproject.toml Outdated
# To avoid module 'numpy.linalg._umath_linalg' has no attribute '_ilp64' in Colab
"numpy>=1.24.4,<2",
"pymatgen>=2025.10.7",
"qe-tools==2.3.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pranabdas pranabdas changed the title SOF-7915: refactor espresso structure parser to use qe-tools SOF-7915: refactor espresso structure parser, add support for non-zero ibrav May 30, 2026
@pranabdas pranabdas changed the title SOF-7915: refactor espresso structure parser, add support for non-zero ibrav SOF-7915: refactor espresso structure parser, support for non-zero ibrav May 30, 2026
from mat3ra.esse.models.properties_directory.structural.lattice import LatticeSchema
from mat3ra.made.cell.primitive_cell import get_primitive_lattice_vectors_from_config

BOHR_TO_ANGSTROM = 0.529177210903

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be in mat3ra-code or mat3ra-utils

# celldm(N) with explicit index
for n, v in re.findall(r"celldm\s*\(\s*(\d+)\s*\)\s*=\s*([^,\n/]+)", block, re.IGNORECASE):
result[f"celldm{n}"] = v.strip()
return result

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions above can be in mat3ra-utils (strip comments might be there already) https://github.com/Exabyte-io/utils/blob/520308cb8a550634abb17501f9fa1aed5c3e9d02/src/py/mat3ra/utils/string.py#L62


lattice_config = LatticeSchema(type=lattice_type, a=a, b=b, c=c, alpha=alpha, beta=beta, gamma=gamma)

return get_primitive_lattice_vectors_from_config(lattice_config)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider the rounding precision for this. Such as RoundNumericValuesMixin in https://github.com/Exabyte-io/made/blob/bfa20b8e723baa55a3b1738e0c4dd100ebec8f50/src/py/mat3ra/made/lattice.py#L12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants